<head>
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=no" />
    <meta charset="utf-8">

    <!-- The Viewer CSS -->
    <link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/style.min.css" type="text/css">

    <!-- Developer CSS -->
    <style>
        body {
            margin: 0;
        }
        #MyViewerDiv {
            width: 100%;
            height: 100%;
            margin: 0;
            background-color: #F0F8FF;
        }
    </style>
</head>
<body>

<!-- The Viewer will be instantiated here -->
<div id="forgeViewer"></div>

<!-- The Viewer JS -->
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/viewer3D.min.js"></script>

<script>
	function getParameterByName(name, url) {
		if (!url) {
			url = window.location.href;
		}
		name = name.replace(/[\[\]]/g, "\\$&");
		var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
			results = regex.exec(url);
		if (!results) return null;
		if (!results[2]) return '';
		return decodeURIComponent(results[2].replace(/\+/g, " "));
	}
</script>
<!-- Developer JS -->
<script>
	var viewer;
	var options = {
		env: 'AutodeskProduction',
		accessToken: getParameterByName('token')
	};
	var urn =  getParameterByName('urn');

	Autodesk.Viewing.Initializer(options, () => {
	    viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'));
	    viewer.start();
	    var documentId = 'urn:' + urn;
	    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
	 });

	/**
	 * Autodesk.Viewing.Document.load() success callback.
	 * Proceeds with model initialization.
	 */

	 function onDocumentLoadSuccess(doc) {
	   var viewables = doc.getRoot().getDefaultGeometry();
	   viewer.loadDocumentNode(doc, viewables).then(i => {
	     // documented loaded, any action?
	   });
	 }

	 function onDocumentLoadFailure(viewerErrorCode) {
	   console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
	 }
 

</script>
</body>